package com.itlaobing.mvc.controller;

import com.itlaobing.mvc.model.Customer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.logging.Logger;

@Controller
@RequestMapping( "/customer/**" )
public class CustomerController {

    private Logger logger = Logger.getLogger( this.getClass().getName() );

    @RequestMapping( "/sign/up/action/1" )
    public String signUpAction1( String username , String password , String confirm , String gender ){
        logger.info( username + " , " + password + " , " + confirm + " , " + gender );

        return "customer/sign-in" ;
    }

    @RequestMapping( "/sign/up/action/2" )
    public String signUpAction2( @RequestParam( "username" ) String uname ,
                                 @RequestParam( "password" ) String passwd ,
                                 String confirm ,
                                 String gender ){
        logger.info( uname + " , " + passwd + " , " + confirm + " , " + gender );

        return "customer/sign-in" ;
    }


    @RequestMapping( "/sign/up/action/3" )
    public String signUpAction3( Customer c , Map<String,Object> map ){
        logger.info( c.toString() );

        map.put( "message" , "恭喜你，注册成功了！(假的)" );

        //     prefix        +      view-name     + suffix
        // "/WEB-INF/views/" + "customer/sign-in" + ".html"
        return "customer/sign-in" ; // 返回 视图名称 ( view-name )
    }

}
